package com.runa.monitor.platinterface.base;

import com.runa.monitor.platinterface.netservice.equipment.dtu.DtuBufferAnalysis;
import com.runa.monitor.platinterface.netservice.equipment.dtu.JunPeiHdDtuBufferAnalysis;
import com.runa.monitor.platinterface.netservice.equipment.furuisi.FuRuiSiClientAnalysis;
import com.runa.protocol.analysis.*;
import com.runa.protocol.enums.ModbusType;
import com.runa.rccprotocol.analysis.*;
import com.runa.rccprotocol.analysis.combination.TouChuanCombinationAnalysis;
import com.runa.rccprotocol.analysis.debao.DeBao2Analysis;
import com.runa.rccprotocol.analysis.debao.DeBaoAnalysis;
import com.runa.rccprotocol.analysis.enleman.EnLeManAnalysis;
import com.runa.rccprotocol.analysis.huizhong.HuiZhongOneAnalysis;
import com.runa.rccprotocol.analysis.huizhong.HuiZhongTempAnalysis;
import com.runa.rccprotocol.analysis.langkabo.LangKaBaoNjFmuAnalysis;
import com.runa.rccprotocol.analysis.langkabo.LangKaBoFmuAnalysis;
import com.runa.rccprotocol.analysis.lanjier.LanJiErFmuAnalysis;
import com.runa.rccprotocol.analysis.lichuang.LiChuangFmuDataAnalysis;
import com.runa.rccprotocol.dto.qiyang.QyConcentratorResponseAnalysis;

/**
 * @author zhuj
 */
public class AnalysisFactory {

    public static MetaBufferAnalysis create(ModbusType modbusType) {
        MetaBufferAnalysis analysis = null;
        switch (modbusType) {
            case MODBUS_RTU:
                analysis = new ModbusBufferRTUAnalysis();
                break;
            case MODBUS_TCP:
                analysis = new ModbusBufferTCPAnalysis();
                break;
            case S7:
                analysis = new S7MessageAnalysis();
            default:
        }
        return analysis;
    }

    public static ShellBufferAnalysis create(String protocol, ModbusType modbusType) {
        ShellBufferAnalysis dtuBufferAnalysis = null;
        MetaBufferAnalysis metaBufferAnalysis = create(modbusType);
        switch (protocol) {
            case "0":
                dtuBufferAnalysis = new DtuBufferAnalysis(metaBufferAnalysis);
            case "50":
                dtuBufferAnalysis = new DtuHDBufferAnalysis(metaBufferAnalysis);
                break;
            case "86":
                dtuBufferAnalysis = new Dtu86BufferAnalysis(metaBufferAnalysis);
                break;
            case "87":
                dtuBufferAnalysis = new DtuCMBufferAnalysis(metaBufferAnalysis, 0);
                break;
            case "88":
                dtuBufferAnalysis = new DtuURBufferAnalysis(metaBufferAnalysis);
            default:
        }
        return dtuBufferAnalysis;
    }

    public static ShellBufferAnalysis create(String protocol) {
        ShellBufferAnalysis dtuBufferAnalysis = null;
        switch (protocol) {
            case "RUNA_FMU":
            case "OTHER_RUNA_FMU":
                dtuBufferAnalysis = new RunaICAnalysis(new RunaEquDataAnalysis());
                break;
            case "HWS_DEVICE":
                dtuBufferAnalysis = new DtuCMBufferAnalysis(new HiwitsDeviceAnalysis(), 1);
                break;
            case "RUNA_LORA":
                dtuBufferAnalysis = new DtuHDBufferAnalysis(new RunaRepeaterAnalysis());
                break;
            case "RUNA_NATIVE":
                dtuBufferAnalysis = new DtuHDBufferAnalysis(new RunaDeviceAnalysis());
                break;
            case "En_Meter":
                dtuBufferAnalysis = new DtuHDBufferAnalysis(new EnAnalysis());
                break;
            case "DFS_CLR":
                dtuBufferAnalysis = new NovoconAnalysis();
                break;
            case "HZ_FMU":
                dtuBufferAnalysis = new HuiZhong41Analysis(new HZDeviceAnalysis());
                break;
            case "FK_NBIot":
                dtuBufferAnalysis = new FKNBAnalysis();
                break;
            case "JJN_FMU":
                dtuBufferAnalysis = new Jjn8124Analysis();
                break;
            case "DAOHENG_FMU":
                dtuBufferAnalysis = new DaoHengAnalysis();
                break;
            case "TIANGANG_FMU":
            case "TIANGANG_UDP_FMU":
                dtuBufferAnalysis = new TianGangAnalysis(new TianGangEquDataAnalysis());
                break;
            case "HUANXIANG_FMU":
                dtuBufferAnalysis = new HuanXiangFmuAnalysis(new HuanXiangEquAnalysis());
                break;
            case "LJE_FMU":
                //兰吉尔下面挂接多个设备，不需要在这里创建传输协议对象
                dtuBufferAnalysis = new LanJiErFmuAnalysis();
                break;
            case "LKB_FMU":
                dtuBufferAnalysis = new LangKaBoFmuAnalysis();
                break;
            case "LKB_DTU":
                dtuBufferAnalysis = new LangKaBaoNjFmuAnalysis(new RunaDeviceAnalysis());
                break;
            case "LC_FMU":
                dtuBufferAnalysis = new LiChuangFmuDataAnalysis(new TouChuanCombinationAnalysis());
                break;
            case "ELM_FMU":
                dtuBufferAnalysis = new EnLeManAnalysis();
                break;
            case "DB_FMU":
                dtuBufferAnalysis = new DeBaoAnalysis();
                break;
            case "DB_2_FMU":
                dtuBufferAnalysis = new DeBao2Analysis();
                break;
            case "HZ_HZ-1_FMU":
                dtuBufferAnalysis = new HuiZhongOneAnalysis();
                break;
            case "JN_TMP":
                dtuBufferAnalysis = new JingNengAnalysis();
                break;
            case "HZ_TMP_FMU":
                dtuBufferAnalysis = new HuiZhongTempAnalysis();
                break;
            case "AP_FMU":
                dtuBufferAnalysis = new ApportionCollectorAnalysis();
                break;
            case "THTF_FMU"://清华同方
                dtuBufferAnalysis = new THTFAnalysis();
                break;
            case "QY_FMU":
                dtuBufferAnalysis = new QiYangAnalysis(new QyConcentratorResponseAnalysis());
                break;
            case "GD_FMU":
                dtuBufferAnalysis = new GdAnalysis();
                break;
            case "HDRX_FMU":
                dtuBufferAnalysis = new HDRXAnalysis();
                break;
            case "JP_HD_DTU":
                dtuBufferAnalysis = new JunPeiHdDtuBufferAnalysis();
                break;
            case "SH_TMP":
                dtuBufferAnalysis = new SmartHeatAnalysis();
                break;
            case "FRS_CLIENT":
                dtuBufferAnalysis = new FuRuiSiClientAnalysis();
                break;
            default:
        }
        return dtuBufferAnalysis;
    }

}
